package com.aihome.springbootjwt.controller;

import com.aihome.springbootjwt.annotation.PassToken;
import com.aihome.springbootjwt.utils.JwtUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangjigang
 * @description token
 * @className TokenController
 * @date 2021/4/16 16:30
 * @vision 1.0.0
 */
@RestController
@RequestMapping("/token")
public class TokenController {

    @PostMapping("/getToken")
    public String getToken() {
        String userId = "1";
        String userName = "hello";
        String token = JwtUtil.createToken(userId, userName);
        return token;
    }

    @PostMapping("/passToken")
    @PassToken
    public String passToken() {
        String token = "no check token";
        return token;
    }

    @PostMapping("/needToken")
    public String needToken() {
        String token = "need check token";
        return token;
    }
}
